package com.design.visitor;

import java.util.ArrayList;

/**
 * @author leali
 * @title: EmployeeList
 * @projectName design
 * @description: EmployeeList
 * @date 2021/12/31 23:46
 */
//员工列表类：对象结构
class EmployeeList {
    //定义一个集合用于存储员工对象
    private final ArrayList<Employee> list = new ArrayList<>();

    public void addEmployee(Employee employee) {
        list.add(employee);
    }

    //遍历访问员工集合中的每一个员工对象
    public void accept(Department handler) {
        for (Employee obj : list) {
            obj.accept(handler);
        }
    }
}
